package photorganizer.common.bean;

import java.util.Properties;

import photorganizer.common.helper.PropertiesHelper;


public class BeanHome {

	private static final String PROPERTIES = "bean.properties";

	private static final Locator locator;

	static {
		Properties properties = PropertiesHelper.load(PROPERTIES);

		Locator singletonLocator = new SingletonLocator();
		Locator mappingLocator = new MappingLocator(singletonLocator, properties);
		Locator dynamicLocator = new DynamicLocator(mappingLocator, properties);
		locator = new CacheLocator(dynamicLocator);
	}

	public static Locator getLocator() {
		return BeanHome.locator;
	}

	/**
	 * @see Locator#get(Class)
	 */
	public static <T> T get(Class<T> beanClass) {
		return locator.get(beanClass);
	}

	private BeanHome() {
		assert false;
	}

}
